import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Card, Table } from 'antd';
import moment from 'moment';

@connect(({ empsearch, loading }) => ({
  loading: loading.models.empsearch,
  empInsSerInfoList: empsearch.empInsSerInfoList, // 社保服务办理列表数据
}))
@Form.create()
class EmpInfor extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {}

  jumpRouting = (targetRouter, insSerHdlId) => {
    const { jumpRouting } = this.props;
    jumpRouting(targetRouter, insSerHdlId);
  };

  render() {
    const { empInsSerInfoList, loading } = this.props;
    const columns = [
      {
        title: '服务类型',
        dataIndex: 'serTypeIdName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '办理状态',
        dataIndex: 'stateName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '客户名称',
        dataIndex: 'custName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '是否有返款',
        dataIndex: 'refundFlagName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '所属客服',
        dataIndex: 'blngCs',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
      },
      {
        title: '操作时间',
        dataIndex: 'operTime',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder' } }),
        render: text => text && moment(text).format('YYYY-MM-DD HH:mm'),
      },
      {
        title: '操作',
        dataIndex: 'operName',
        onHeaderCell: () => ({ style: { fontWeight: 'bolder', width: 150 } }),
        render: (text, record) => (
          <span
            style={{ color: '#1890FF', cursor: 'pointer' }}
            onClick={() => this.jumpRouting('insSerHdlId', record.insSerHdlId)}
          >
            查看
          </span>
        ),
      },
    ];
    return (
      <div>
        <Card title={<span style={{ fontWeight: 'bolder' }}>社保服务办理</span>}>
          <Table
            rowSelection={null}
            columns={columns}
            dataSource={empInsSerInfoList && empInsSerInfoList.list}
            loading={loading}
            rowKey="insSerHdlId"
            pagination={false}
          />
        </Card>
      </div>
    );
  }
}

export default EmpInfor;
